$("#myCarousel").carousel('pause');

$('#prev').on('click', function () {
    var newposition = parseInt($('#leftLubo').css('marginTop')) + 138;
    if (newposition > 0) {
        newposition = -276;
    }
    $('#leftLubo').animate({
        marginTop: newposition
    }, 550);
});

$('#next').on('click', function () {
    var newposition = parseInt($('#leftLubo').css('marginTop')) - 138;
    if (newposition < -276) {
        newposition = 0;
    }
    $('#leftLubo').animate({
        marginTop: newposition
    }, 550);

});

var alTime = true;
setTimeout(function () {
    $("#myCarousel").carousel('cycle');
}, 0);
var lTimer = setInterval(function () {
    var newposition = parseInt($('#leftLubo').css('marginTop')) - 138;
    if (newposition < -276) {
        newposition = 0;
    }
    $('#leftLubo').animate({
        marginTop: newposition
    }, 530);
}, 5000);

$('#myCarousel').mouseover(function () {
    clearInterval(lTimer);
});

$('#myCarousel').mouseout(function () {
    lTimer = setInterval(function () {
        var newposition = parseInt($('#leftLubo').css('marginTop')) - 138;
        if (newposition < -276) {
            newposition = 0;
        }
        $('#leftLubo').animate({
            marginTop: newposition
        }, 550);
    }, 5000);
});

